package com.example.stock.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.stock.dto.ratio.RatioReq;
import com.example.stock.entity.ratio.RatioEnity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ：Zhengyu Wang
 * @date ：Created in 2023/4/11 23:42
 * @description：
 * @modified By：
 * @version: $
 */

@Mapper
public interface RatioMapper extends BaseMapper<RatioEnity> {

    @Select(
            "SELECT sd.id, sd.stock_name, sd.day_time, sd.close_price, " +
                    "bf.weight_factor, sd.close_price * bf.weight_factor as real_price " +
                    "FROM stock_days sd " +
                    "JOIN back_weight_factor bf " +
                    "ON sd.day_time = bf.day_time " +
                    "AND sd.stock_name = bf.stock_code " +
                    "${ew.customSqlSegment} "
    )
    List<RatioEnity> getParameters(@Param(Constants.WRAPPER) Wrapper<RatioReq> queryWrapper);

}
